Thread: Trouble reading UTF-16

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    Trouble reading UTF-16

    I'm trying to read utf-16 using stdio function fgetws(), but it is only assigning a single byte to each variable in the wchar_t string.
    Anyone know whats happening? Cheers.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    When not in binary mode, fgetws() reads a single-byte encoding and converts into a whcar_t encoding (UTF16LE on windows, or UTF/UCS-32 LE/BE on *nix).

    If you know how the file is encoded, then open and read the file in binary mode.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another trouble with semaphores
    By jsrig88 in forum C Programming
    Replies: 2
    Last Post: 11-05-2009, 05:33 AM
  2. Reading a 16 bit Register
    By Bladactania in forum C Programming
    Replies: 7
    Last Post: 07-04-2009, 03:15 PM
  3. Replies: 3
    Last Post: 03-05-2009, 03:14 AM
  4. Trouble reading from file
    By neolyn in forum C++ Programming
    Replies: 5
    Last Post: 12-11-2004, 02:48 PM
  5. having trouble reading data from a file
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 11-08-2001, 11:15 AM